/***********************************************************************
	filename: 	DaterRecLogin.h
	created:	22/4/2012
	author:		4Ys
	
	purpose:	Implements classes to recover orders from server to client,
				specifically for event.	            
*************************************************************************/

#include "DaterRecLogin.h"
#include "DaterUserManager.h"
#include <iostream>

namespace Dater
{
	//Login
	User* RecLogin::execute()
	{
		if(_splitedData[1] == "1")
		{
			int uid;
			std::string email, account, hypocorism, gender, birthday;
			uid = atoi(_splitedData[2].c_str());
			email = _splitedData[3];
			account = _splitedData[4];
			hypocorism = _splitedData[5];
			gender = _splitedData[6];
			birthday = _splitedData[7];
			_eventidCounter = atoi(_splitedData[8].c_str());
			User* addedUser = UserManager::getSingleton().addRelatedUser(uid, hypocorism, gender, birthday);
			addedUser->setEmail(email);
			addedUser->setAccount(account);

			return addedUser;
		}
		else
		{
			_errorMsg = _splitedData[2];
			return NULL;
		}
	}
}